<?php
//No direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

class OwnserviceViewLevels extends JView
{
	function display($tpl=null) 
	{
		global $mainframe, $option;

		//Initialise variables
		$document	= & JFactory::getDocument();
		$user		= & JFactory::getUser();
		$ownuser	= & Ownservice::getUser();
		$params 	= & $mainframe->getParams('com_ownservice');
		$pathway  	= & $mainframe->getPathway();
		
		//Set page title information
		$menus		= &JSite::getMenu();
		$menu		= $menus->getActive();

		//check permission for manage levels
		if($user->gid < 25) 
		{
			if (!Ownservice::checkAccess( 'vip', 'manage' )) {
				JError::raiseWarning(500, JText::_('ALERTNOTAUTH') );
				$mainframe->redirect(JRoute::_('index.php?option=com_ownservice'));
			}
		}

		$filter_order		= $mainframe->getUserStateFromRequest( $option.'.level.filter_order', 'filter_order', 'from', 'cmd' );
		$filter_order_Dir	= $mainframe->getUserStateFromRequest( $option.'.level.filter_order_Dir',	'filter_order_Dir',	'ASC', 'word' );

		//add css to document
		$document->addStyleSheet(JURI::base().'components/com_ownservice/assets/css/style.css');
		$document->addStyleSheet(JURI::base().'components/com_ownservice/assets/css/nav.css');
		$document->addStyleSheet(JURI::base().'components/com_ownservice/assets/css/icon.css');
		//add java script to document
		$document->addScript(JURI::base().'components/com_ownservice/assets/js/ownservice.js');

		// Get data from the model
		$rows 		=& $this->get('Items');
		$pageNav	=& $this->get( 'Pagination' ); 

		//set page title
		$params->set('page_title',	JText::_('OWNSERVICE_LEVELS'));
		$document->setTitle( $params->get('page_title') );

		$lists = array();

		// table ordering
		$lists['order_Dir'] = $filter_order_Dir;
		$lists['order'] = $filter_order;

		//assign data to document
		$this->assignRef('params', $params);
		$this->assignRef('lists', $lists);
		$this->assignRef('rows', $rows);
		$this->assignRef('pageNav', $pageNav);

		parent::display($tpl);
	}
}